package com.ruoyi.function.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.function.domain.SysDeptRoad;
import com.ruoyi.function.service.ISysDeptRoadService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 路段管理Controller
 * 
 * @author ruoyi
 * @date 2025-10-04
 */
@RestController
@RequestMapping("/function/SysDeptRoad")
public class SysDeptRoadController extends BaseController
{
    @Autowired
    private ISysDeptRoadService sysDeptRoadService;

    /**
     * 查询路段管理列表
     */
    @PreAuthorize("@ss.hasPermi('function:SysDeptRoad:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysDeptRoad sysDeptRoad)
    {
        startPage();
        List<SysDeptRoad> list = sysDeptRoadService.selectSysDeptRoadList(sysDeptRoad);
        return getDataTable(list);
    }

    /**
     * 导出路段管理列表
     */
    @PreAuthorize("@ss.hasPermi('function:SysDeptRoad:export')")
    @Log(title = "路段管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysDeptRoad sysDeptRoad)
    {
        List<SysDeptRoad> list = sysDeptRoadService.selectSysDeptRoadList(sysDeptRoad);
        ExcelUtil<SysDeptRoad> util = new ExcelUtil<SysDeptRoad>(SysDeptRoad.class);
        util.exportExcel(response, list, "路段管理数据");
    }

    /**
     * 获取路段管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('function:SysDeptRoad:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysDeptRoadService.selectSysDeptRoadById(id));
    }

    /**
     * 新增路段管理
     */
    @PreAuthorize("@ss.hasPermi('function:SysDeptRoad:add')")
    @Log(title = "路段管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysDeptRoad sysDeptRoad)
    {
        return toAjax(sysDeptRoadService.insertSysDeptRoad(sysDeptRoad));
    }

    /**
     * 修改路段管理
     */
    @PreAuthorize("@ss.hasPermi('function:SysDeptRoad:edit')")
    @Log(title = "路段管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysDeptRoad sysDeptRoad)
    {
        return toAjax(sysDeptRoadService.updateSysDeptRoad(sysDeptRoad));
    }

    /**
     * 删除路段管理
     */
    @PreAuthorize("@ss.hasPermi('function:SysDeptRoad:remove')")
    @Log(title = "路段管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysDeptRoadService.deleteSysDeptRoadByIds(ids));
    }
}
